<?PHP
require_once WACT_ROOT.'controller/controller.inc.php';
require_once APP_ROOT.'view/pub/layoutright.view.php';
require_once APP_ROOT.'model/common/session.php';
require_once APP_ROOT.'model/common/user.php';
require_once APP_ROOT.'model/common/league.php';
require_once APP_ROOT.'model/common/date.php';
require_once APP_ROOT . "model/common/site.php";


class LeaguesPrintDetailView extends View {
	function LeaguesPrintDetailView($TemplateFile){
		parent::View($TemplateFile);

	}

	function prepare(&$controller, &$request, &$responseModel){
		parent::prepare(&$controller, &$request, &$responseModel);
		$docbase="http://".$_SERVER['HTTP_HOST'];
		$this->Template->set('docbase',$docbase);

			$league_id=$request->getParameter('id');

		$this->Template->set('league_id',$league_id);

		$league=&League::getRecord($league_id);

		if(Session::isLogin()&&Session::getUserId()==$league->get('user_id'))
			$this->Template->set('author',' ');

                
		$this->Template->set('SITE_CSS',Site::getSiteTemplateCSS());
		$this->Template->set('SITE_BASE',Site::getSiteTemplateBase());
		$this->Template->set('SITE_TITLE',Site::getTitle());
		$this->Template->set('title',Site::getTitle().'- Camp/League profile  - '.$league->get('name'));

 

		$datestr=$league->get('date_added');
		$mydate=strtotime($datestr);
        $tz =& new MyTimeZone();
        $mydate = $tz->timeGMT($mydate);
		$datestr = gmstrftime('%b %d, %Y',$mydate);
		$this->Template->set('date_added',$datestr);

		$prem=$league->get('premium');
		if($prem&&$prem==0) $prem=null;
		$this->Template->set('prem',$prem);

		$this->Template->set('name',$league->get('name'));



		$event=&League::getEventName($league->get('event'));
		$this->Template->set('event',$event);

		$category1=$league->get('category1');
		$category2=$league->get('category2');

		//categories
		if($category1) {
			$category=$category1;
			if($category2)	$category.='/'.$category2;
			$this->Template->set('category',$category);
		} else if($category2){
			$this->Template->set('category',$category2);
		}



		//school
		$org=$league->get('org_title');
		if($org)$this->Template->set('org_title',$org);

		$location=null;
		$saddress=$league->get('org_address');
		$scity=$league->get('org_city');
		$sstate=$league->get('org_state');
		$szip=$league->get('org_zip');
		$sphone=$league->get('org_phone');
		$semail=$league->get('org_email');
		if($saddress) {
			$this->Template->set('org_address',$saddress);
			$location=' ';
		}
		if($scity) $location=$scity;
		if($sstate&&$sstate!='(N') $location.=', '.$sstate;
		if($szip) $location.=' '.$szip;
		if($location&&$location!=' ')
			$this->Template->set('org_lastaddress',$location);
		if($sphone) {
			$location='Phone: '.$sphone;
			$this->Template->set('org_phone',$location);
		}
		if($semail) {
			$location='Email: '.$semail;
			$this->Template->set('org_email',$location);
		}
		if($location)$this->Template->set('org_location',true);

		$other=$league->get('additional');
		if($other) $this->Template->set('other',$other);

		if(APP_NAME!=""){
			$this->Template->set('app_name',HOST."/".APP_NAME);
		} else $this->Template->set('app_name',HOST);

	}

}



class LeaguesPrintDetailPage extends PageController{
	function LeaguesPrintDetailPage() {
		parent::PageController();

        $mytemplate1 = 'pub/leagues/print_detail.html';
       
		$this->setDefaultView(new LeaguesPrintDetailView($mytemplate1));

	}

}




?>
